home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1984 January to June
/
Ahoy_Magazine_84-Jan-Jun_1984_Double_L.d64
/
relative files
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
39 lines
5 rem--ahoy--feb issue--relative files--prog page 27
10 print"[147]phone book -- relative file demo":open15,8,15,"i0"
20 print"setup new file (y/n)?";
30 geta$:ifa$<>"n"anda$<>"y"then30
40 ifa$="n"thenprint"no":goto60
50 print"yes":open3,8,3,"@0:phonefile,l,"+chr$(40):goto100
60 open7,8,7,"counter,s,r":input#7,n:close7:open3,8,3,"phonefile"
100 print"[147]choose one:":print"1- enter name, number":print"2- search for name"
110 print"3- display all entries":print"4- exit"
120 print"enter choice-->";
130 geta$:a=val(a$):ifa<1ora>4then130
140 onagoto200,400,600,800
200 print"[147]active entries ="n
205 ifn=255thenprint"no more room in file.":gosub990:goto100
210 print"enter name, number:":i$="":j$=i$:inputi$,j$:ifi$=""orj$=""then100
220 iflen(i$)+len(j$)>37thenprint"entry is too long...":goto210
230 n=n+1:print#15,"p"chr$(3)chr$(n)chr$(0):print#3,i$","j$:goto100
400 ifn=0thenprint"no entries in file.":gosub990:goto100
405 print"[147]enter name to search for:":n$="":inputn$:ifn$=""then100
410 j=0:forx=1ton:print#15,"p"chr$(3)chr$(x)chr$(0):input#3,i$,j$
415 ifi$<>n$then430
420 x=n:j=n
430 next:ifj=0thenprint"not found.":gosub990:goto100
440 printn$,j$:gosub990:goto100
600 print"[147]hit f1 to pause and continue"
610 ifn=0thenprint"no entries in file.":gosub990:goto100
620 forx=1ton:print#15,"p"chr$(3)chr$(x)chr$(0):input#3,i$,j$:printi$,j$
625 geta$:ifa$<>"[133]"then630
627 geta$:ifa$<>"[133]"then627
630 next:gosub990:goto100
800 print"[147]exit, are you sure (y/n)? ";
810 geta$:ifa$<>"n"anda$<>"y"then810
820 ifa$="n"thenprint"no":goto100
830 print"yes":open7,8,7,"@0:counter,s,w":print#7,n:close7:input#15,a,b$,c,d
840 close15:end
990 print"hit return to continue."
995 geta$:ifa$<>chr$(13)then995
999 return